﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using log4net;
using log4net.Config;

namespace Log4Net
{
    static class Program
    {
        //调用特定app用于记录特定log
        private static readonly ILog logApp = LogManager.GetLogger("app");
        //找不到对应log时，使用默认root的log
        private static readonly ILog log = LogManager.GetLogger(typeof(Program));
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            string cfg = System.Configuration.ConfigurationManager.AppSettings["log4net"];
            System.IO.FileInfo cfgFileInfo=new System.IO.FileInfo(cfg);
            if (!cfgFileInfo.Exists) return;
            XmlConfigurator.Configure(cfgFileInfo);
            log.Info("App start");
            logApp.Error("App error");
            Application.Run(new Form1());
        }
    }
}
